import java.time.ZonedDateTime

import scala.util.Random

object TestCimney extends App {

  case class MakeCoffee(id: Int, kind: String, addict: String)

  case class CoffeeMade(id: Int, kind: String, forAddict: String, at: ZonedDateTime)

  val command = MakeCoffee(id = Random.nextInt,
    kind = "Espresso",
    addict = "Piotr")

  import io.scalaland.chimney.dsl._



  val event = command.into[CoffeeMade]
    .withFieldComputed(_.at, _ => ZonedDateTime.now)
    .withFieldRenamed(_.addict, _.forAddict)
    .transform
  println(event)


  class TestM{
    val id=Random.nextInt()
  }

  val event2=Map[String,Any]("id"->Random.nextInt()).into[CoffeeMade].
    withFieldComputed(_.id,_=>event.id).withFieldComputed(_.kind,_=> "") .
    withFieldComputed(_.at, _ => ZonedDateTime.now).
    withFieldComputed(_.forAddict,_=>"haha")
    .transform

  println(event2)

  case class Foo(x: String, y: Int)

  case class Bar(x: String, y: Int, z: Boolean = true)

  Foo("abc", 10).transformInto[Bar]

}
